/**
 * HSI-88.h
 *
 * HSI-88 Fast S88 PC Interface 
 * 
 * This software emulates the HSI-88 from Littfinski. It has three S88 busses that it activly scans only reporting the changed
 * signals to the PC.
 *
 * Author:   Elze Kool <efrkool@live.nl>
 * Date:     27-nov-2009
 * Software: AVR-GCC
 * Target:   AT90USB162 @ 8Mhz on the Olimex AVR-USB-162 development board
 *
 * Based on the LUFA USB Library and Serial CDC Example:
 * Parts Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 *
 */
 
#ifndef _RINGBUFF_H_
#define _RINGBUFF_H_

	/**
	 * Type of element to store
	 **/
	typedef volatile uint8_t RingBuffer_Data_t;
	
	/**
	 * Type definition of RingBuffer type
	 **/
	typedef volatile struct
	{
		/**
		 * Storage for Ringbuffer
		 * Memory is allocated on RingBuffer_Initialize
		 **/
		RingBuffer_Data_t* Storage;
		
		/**
		 * Position in storage to put new elements
		 **/
		uint32_t LoadPosition;
		
		/**
		 * Position in storage to get element from
		 **/
		uint32_t ReadPosition;
		
		/**
		 * Number of elements currently stored in buffer
		 **/
		uint32_t Count;
		
		/**
		 * Size of Ring Buffer
		 **/
		uint32_t Size;
		
	} RingBuffer_t;
	 

	// Ring Buffer functions
	void RingBuffer_Initialize(RingBuffer_t* Buffer, uint32_t Size);
	void RingBuffer_Reset(RingBuffer_t* Buffer);
	void RingBuffer_AddElement(RingBuffer_t* Buffer, RingBuffer_Data_t Element);
	RingBuffer_Data_t RingBuffer_GetElement(RingBuffer_t* Buffer);
		
#endif